package org.ala.tiktools.rpc.plugin.node;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 节点状态
 *
 * @author ala
 * @date 2025-04-05 15:59
 */
public enum NodeStatusEnums {
    NEW(0, "新建"),
    BEGIN_ACTIVATE(1, "激活中"),
    ACTIVATE(2, "激活"),
    UNAVAILABLE(-1, "不可用"),
    KILL(-2, "摘除")
    ;
    private int val;
    private String desc;

    NodeStatusEnums(int val, String desc) {
        this.val = val;
        this.desc = desc;
    }


    static Map<Integer, NodeStatusEnums> valMapper = null;
    public static NodeStatusEnums val(int val) {
        if (valMapper == null) {
            synchronized (NodeStatusEnums.class) {
                if (valMapper == null) {
                    valMapper = Arrays.stream(values()).collect(Collectors.toMap(
                            t -> t.val,
                            t -> t,
                            (o,n) -> n));
                }
            }
        }
        return valMapper.get(val);
    }


    public int getVal() {
        return val;
    }

    public void setVal(int val) {
        this.val = val;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }
}
